<template>
  <div class="shop-list-wrap">
    <div class="shop-list-title">商品列表<span @click="handleShoplist"><img src="@/assets/images/copy.png" alt=""></span></div>
    <div class="shop-list-content">
      <div class="w-goods-list">
        <div class="w-goods-item" v-for="(item,i) in shops" :key="i" >
          <div class="w-goods-item-inner">
            <img :src="item.logo" alt="">
            <div class="w-goods-item-name">{{item.title}}</div>
            <div class="w-goods-item-price">
              <span>¥{{item.price}}</span>
              <!-- <span>¥689</span> -->
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="shop-list-sub">
      <span>共{{pieces}}件</span>
      <span class="shop-list-total">总价</span>
      <span class="shop-list-num">￥{{total}}</span>
      <div class="btn-addcar" @click="addCar">加入购物车</div>
    </div>
    
  </div>
</template>

<script>
export default {
  props: {
    shops: {
      type: Array,
      default: function() {
        return [];
      }
    }
  },
  data() {
    return {
      isShowPopup: false,
      pieces: 0,
      info: []
    };
  },
  watch: {
    shops(v) {
      this.pieces = v.length;
      this.info = v;
    }
  },
  computed: {
    total() {
      let sum = 0;
      this.info.forEach(item => {
        sum += item.price;
      });
      return sum;
    }
  },
  methods: {
    handleShoplist() {
      this.$emit("handleParent");
    },
    addCar() {
      this.$emit("handlePop");
    }
  }
};
</script>

<style lang="scss">
.shop-list-wrap {
  height: 994px;
  display: flex;
  flex-direction: column;
  background: #fff;
  position: fixed;
  bottom: 0;
  width: 1080px;

  .shop-list-title {
    height: 100px;
    line-height: 100px;
    font-size: 40px;
    font-weight: 500;
    color: #333333;
    padding-left: 48px;

    img {
      width: 48px;
      height: 48px;
      vertical-align: middle;
    }

    span {
      float: right;
      margin-right: 80px;
    }
  }
  .shop-list-content {
    flex: 1;
    overflow: auto;
    padding: 0 48px;
    .w-goods-item {
      display: inline-block;
      vertical-align: top;
      width: 50%;
      height: 374px;
      border-top: 2px solid #e5e2e2;

      .w-goods-item-inner {
        width: 320px;
        height: 320px;
        margin: 0 auto;
      }
      img {
        margin: 20px 0 16px 0;
        width: 100%;
        height: 238px;
      }
      .w-goods-item-name {
        font-size: 28px;
        margin-bottom: 20px;
        font-weight: 500;
      }
      .w-goods-item-name,
      .w-goods-item-price {
        padding-left: 32px;
      }
      .w-goods-item-price {
        font-size: 28px;
        color: #d0021b;
        span:nth-child(2) {
          color: #9b9b9b;
          margin-left: 36px;
          text-decoration-line: line-through;
        }
      }
    }
    .w-goods-item:nth-child(odd) {
      border-right: 2px solid #e5e2e2;
    }
    .w-goods-item:nth-child(even) {
      margin-left: -2px;
    }
  }
  .shop-list-sub {
    height: 120px;
    line-height: 120px;
    border-top: 1px solid #e6e6e6;
    padding: 0 48px;
    position: relative;
    color: #333333;
    font-size: 32px;
    .shop-list-total {
      margin-left: 40px;
    }
    .shop-list-num {
      margin-left: 16px;
      color: #d0021b;
      font-size: 40px;
      font-weight: 500;
    }
    .btn-addcar {
      border-radius: 50px;
      background: #5252a1;
      color: #fff;
      position: absolute;
      top: 22px;
      right: 48px;
      width: 308px;
      height: 76px;
      text-align: center;
      line-height: 76px;
    }
  }
}
</style>
